
#if 0
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s1;
    cin >> s1;
    int len1 = s1.length();
    for(int i = 0;i < len1;i++)
    {
        if(s1[i]!= ' ')
            continue;
        for(int j = i + 1;j < len1;j++)
        {
            if(s1[j] == ' ')
            {
                s1.erase(i,1);
            }

        }
    }
    cout << s1 << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
int arr[10005] ;
int main()
{
    int l = 0, m = 0;
    cin >> l >> m;
    for(int i = 0;i <= l;i++)
    {
        arr[i] = 1;
    }
    while(m--)
    {
        int a = 0, b = 0;
        cin >> a >> b;
        for(int i = a;i <= b;i++)
        {
            arr[i] = 0;
        }
    }
    int sum = 0;
    for(int i = 0;i <= l;i++)
    {
        sum+=arr[i];
    }
    cout << sum << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int arr[15][15] = {0}, x = 1, y = 1,mark = 1;
    int n = 0;
    cin >> n;
    arr[x][y] = mark;
    while(mark < n * n)
    {
        while(arr[x][y + 1] == 0 && y + 1 <= n)
        {
            y++,mark++;
            arr[x][y] = mark;
        }
        while(arr[x + 1][y] == 0 && x + 1 <= n)
        {
            x++,mark++;
            arr[x][y] = mark;
        }
        while(arr[x][y - 1] == 0 && y- 1 >= 1)
        {
            y--,mark++;
            arr[x][y] = mark;
        }
        while(arr[x - 1][y] == 0 && x - 1 >= 1)
        {
            x--;mark++;
            arr[x][y] = mark;
        }

    }
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= n;j++)
        {
            cout << setw(3) << arr[i][j];
        }
        cout << endl;
    }
    return 0;
}
#endif
#include<bits/stdc++.h>
 using namespace std;
 int arr[13],balance,desport,res;
 int main()
 {
     int f = 0;
     for(int i = 1;i < 13;i++)
     {
         cin >> arr[i];
     }
     for(int i =1;i < 13;i++)
     {
         balance+=300;
         balance = balance - arr[i];
         if(balance < 0)
         {
             f = i;
             break;
         }
         else
         {
             if(balance / 100 != 0)
             {
                 int t = balance / 100;
                 desport += t * 100;
                 balance-= t * 100;
             }
         }

     }

     if(f)
     {
         cout << '-' << f;
     }
     else
     {
         res = (desport/10) * 12 + balance;
         cout << res << endl;
     }
 }